<template>
  <div class="app-container">
    <loading v-show="loading"></loading>
  <el-card class="box-card searchFormStyle" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>党务信息操作</span>
    </div>
    <div class="text item">
      <el-form ref="searchData" :model="searchData" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item  label="党支部考核周期">
               <el-select v-model="searchData.cycleAssessmenKey" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in cycleAssessmenKeyList"
                    :key="item.cycleAssessmenKey"
                    :label="item.assessmenCycle"
                    :value="item.cycleAssessmenKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类型">
               <el-select v-model="searchData.partyWorkTypeKey" placeholder="请选择党务工作类型"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkTypeKeyList"
                    :key="item.partyWorkTypeKey"
                    :label="item.typeName"
                    :value="item.partyWorkTypeKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类别">
               <el-select v-model="searchData.partyWorkSort" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkSortList"
                    :key="item.paramValue"
                    :label="item.paramName"
                    :value="item.paramValue">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item>
              <el-button type="primary" 
              icon="el-icon-plus" 
              v-if="permissionHandle('partyType:openDialog')"
              @click="openDialog">新 增</el-button>
              <el-button type="primary" 
              icon="el-icon-search"
               v-if="permissionHandle('partyType:getList')"
               @click="getList">查 询</el-button>
               <el-button type="primary" 
              icon="el-icon-refresh"
               v-if="permissionHandle('partyType:getList')"
               @click="resetSearch">重 置</el-button>
              <el-button type="info" 
              icon="el-icon-delete"
               v-if="permissionHandle('partyType:handleDelete')" 
              @click="deleteParamsType">删 除</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </el-card>
  <el-card class="box-card" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>党务类型列表</span>
    </div>
    <el-table
      :data="tableData"
      border
      ref="tableData"
      style="width: 100%;margin-bottom:1%;"
      @selection-change="handleSelectionChange"
      >
      <el-table-column
        type="selection"
        width="40">
      </el-table-column>
      <el-table-column
        label="年度考核名称"
        >
        <template slot-scope="scope">
            {{ scope.row.cycleAssessmenKey }}
        </template>
      </el-table-column>
      <el-table-column
        label="党组织机构名称"
        >
        <template slot-scope="scope">
            {{ scope.row.partyOrgKey }}
        </template>
      </el-table-column>
      <el-table-column
        label="党务工作类别"
        >
        <template slot-scope="scope">
            {{ scope.row.partyWorkSort }}
        </template>
      </el-table-column>
      <el-table-column
        label="党务工作类型"
        >
        <template slot-scope="scope">
            {{ scope.row.partyWorkTypeKey }}
        </template>
      </el-table-column>
      <el-table-column
        label="记录人"
        >
        <template slot-scope="scope">
            {{ scope.row.recordUser }}
        </template>
      </el-table-column>
      <el-table-column
        label="创建日期"
        width="180"
      >
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="300px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            icon="el-icon-document"
            v-if="permissionHandle('partyDues:handleEdit')"
            @click="handledetail(scope.$index, scope.row)">详细</el-button>
          <el-button
            size="mini"
            icon="el-icon-edit-outline"
            v-if="permissionHandle('partyDues:handleEdit')"
            @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          <el-button
            size="mini"
            icon="el-icon-delete"
            type="danger"
            v-if="permissionHandle('partyType:handleDelete')"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :paginations="paginations"></pagination>
  </el-card>
  <!--新增参数类型-->
  <el-dialog title="新增党务信息" :visible.sync="dialogFormVisible" width="80%" id="dialogs">
    <el-form :model="addForm" :rules="rules" ref="addForm" label-width="160px">
      <el-row>
          <el-col :span="8">
            <el-form-item  label="党支部考核周期" prop="cycleAssessmenKey">
               <el-select v-model="addForm.cycleAssessmenKey" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in cycleAssessmenKeyList"
                    :key="item.cycleAssessmenKey"
                    :label="item.assessmenCycle"
                    :value="item.cycleAssessmenKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类型" prop="partyWorkTypeKey">
               <el-select v-model="addForm.partyWorkTypeKey" placeholder="请选择党务工作类型"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkTypeKeyList"
                    :key="item.partyWorkTypeKey"
                    :label="item.typeName"
                    :value="item.partyWorkTypeKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类别" prop="partyWorkSort">
               <el-select v-model="addForm.partyWorkSort" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkSortList"
                    :key="item.paramValue"
                    :label="item.paramName"
                    :value="item.paramValue">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item  label="党务工作名称" prop="workTitle">
                <el-input v-model="addForm.workTitle" placeholder="请输入党务工作名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="附件"  prop="fileKey">
                <el-input type="hidden" v-model="addForm.fileKey"></el-input>
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :show-file-list="showFilelist"
                  :action="importFileUrl"
                  :data="importData"
                  :on-preview="handlePreview"
                  :before-upload="beforeAvatarUpload"
                  :onError="uploadError"
                  :onSuccess="uploadSuccess"
                  :file-list="fileList"
                  :on-remove="handleRemove"
                  >
                  <el-button style="margin-left: 10px;" size="small" icon="el-icon-edit-outline">上传附件</el-button>
                </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">
          <el-col :span="8">
            <el-form-item  label="主持人"  prop="hostUser">
                <el-input v-model="addForm.hostUser" placeholder="请输入主持人"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="记录时间"  prop="recordTime">
                <el-date-picker
                v-model="addForm.recordTime"
                type="datetime"
                value-format="yyyy-MM-dd HH:mm:ss"
                placeholder="选择记录时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="应到人数"  prop="shouldNumber">
                <el-input v-model="addForm.shouldNumber" placeholder="请输入应到人数"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="实到人数"  prop="actualNumber">
                <el-input v-model="addForm.actualNumber" placeholder="请输入应到人数"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="到会人员"  prop="joinUser">
                <el-input v-model="addForm.joinUser" placeholder="请输入应到人数"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="缺席人员及原因"  prop="absentUser">
                <el-input type="textarea" v-model="addForm.absentUser" placeholder="请输入应到人数"></el-input>
            </el-form-item>
          </el-col>
          <el-col   v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">
            <el-form-item  label="工作内容">
              <div class="editor-container" >
                <UE :defaultMsg="defaultMsg" :value="valueText" :id="editor" :config="config" ref="ue"></UE>
              </div>
            </el-form-item>
          </el-col>    
        </el-row>
        <el-row v-if="addForm.partyWorkSort && addForm.partyWorkSort==='002'"  :gutter="20">
            <el-col :span="16">
              <el-form-item label="在线会议起始时间" prop="onlineBegintime">
                <input type="hidden" v-model="addForm.onlineBegintime = SeTime[0]">
                <input type="hidden" v-model="addForm.onlineEndtime = SeTime[1]">
                <el-date-picker
                  v-model="SeTime"
                  type="datetimerange"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  range-separator="-"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item  label="附件上传结束时间"  prop="onlineFileEndtime">
                  <el-date-picker
                  v-model="addForm.onlineFileEndtime"
                  type="datetime"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  placeholder="选择附件上传结束时间">
                </el-date-picker>
              </el-form-item>
          </el-col>
        </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button icon="el-icon-refresh" @click="resetForm('addForm')">重置</el-button>
      <el-button type="primary" icon="el-icon-plus" @click="submitForm('addForm')">保存</el-button>
    </div>
  </el-dialog>
    <!-- <div class="info">UE编辑器示例<br>需要使用编辑器时，调用UE公共组件即可。可设置填充内容defaultMsg，配置信息config(宽度和高度等)，可调用组件中获取内容的方法。</div>
    <button @click="getUEContent()">获取内容</button>
    <div class="editor-container">
      <UE :defaultMsg="defaultMsg" :id="editor" :config="config" ref="ue"></UE>
    </div> -->
    <el-dialog title="党务信息详细" :visible.sync="detailFormVisible" width="80%" >
      <el-form :model="addForm" :rules="rules" :disabled="true" ref="addForm" label-width="140px" class="detailStyle">
        <el-row>
          <el-col :span="8">
            <el-form-item  label="党支部考核周期:" prop="cycleAssessmenKey">
               <el-select v-model="addForm.cycleAssessmenKey" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in cycleAssessmenKeyList"
                    :key="item.cycleAssessmenKey"
                    :label="item.assessmenCycle"
                    :value="item.cycleAssessmenKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类型:" prop="partyWorkTypeKey">
               <el-select v-model="addForm.partyWorkTypeKey" placeholder="请选择党务工作类型"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkTypeKeyList"
                    :key="item.partyWorkTypeKey"
                    :label="item.typeName"
                    :value="item.partyWorkTypeKey">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item  label="党务工作类别:" prop="partyWorkSort">
               <el-select v-model="addForm.partyWorkSort" placeholder="请选择党支部考核周期"  class="tree-select">
                  <el-option
                    v-for="item in partyWorkSortList"
                    :key="item.paramValue"
                    :label="item.paramName"
                    :value="item.paramValue">
                  </el-option>
                </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
            <el-col :span="8">
              <span class="labelSpan">
                党务工作名称:
              </span>
              <span class="valueSpan">
                {{addForm.workTitle}}
              </span>
            </el-col>
            <el-col :span="8">
            <el-form-item label="附件:"  prop="fileKey">
                <el-input type="hidden" v-model="addForm.fileKey"></el-input>
                <el-upload
                  class="upload-demo"
                  ref="upload"
                  :show-file-list="showFilelist"
                  :action="importFileUrl"
                  :data="importData"
                  :on-preview="handlePreview"
                  :before-upload="beforeAvatarUpload"
                  :onError="uploadError"
                  :onSuccess="uploadSuccess"
                  :file-list="fileList"
                  :on-remove="handleRemove"
                  >
                </el-upload>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">
          <el-col :span="8">
              <span class="labelSpan">
                主持人:
              </span>
              <span class="valueSpan">
                {{addForm.hostUser}}
              </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                记录时间:
              </span>
              <span class="valueSpan">
                {{addForm.recordTime}}
              </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                应到人数:
              </span>
              <span class="valueSpan">
                {{addForm.shouldNumber}}
              </span>
          </el-col>   
        </el-row>
        <el-row  v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">
           <el-col :span="8">
            <span class="labelSpan">
              实到人数:
            </span>
            <span class="valueSpan">
              {{addForm.actualNumber}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
              到会人员:
            </span>
            <span class="valueSpan">
              {{addForm.joinUser}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
              缺席人员及原因:
            </span>
            <span class="valueSpan">
              {{addForm.absentUser}}
            </span>
          </el-col>
        </el-row>
        <el-row  v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">           
          <el-col   v-if="addForm.partyWorkSort && addForm.partyWorkSort==='001'">
            <span class="labelSpan">
              工作内容:
            </span>
            <span class="valueSpan" v-html="addForm.content">
            </span>
          </el-col> 
        </el-row>
        <el-row v-if="addForm.partyWorkSort && addForm.partyWorkSort==='002'"> 
            <el-col :span="8">
              <span class="labelSpan">
                在线会议开始时间:
              </span>
              <span class="valueSpan">
                {{addForm.onlineBegintime}}
              </span>
            </el-col>
            <el-col :span="8">
              <span class="labelSpan">
                在线会议结束时间:
              </span>
              <span class="valueSpan">
                {{addForm.onlineEndtime}}
              </span>
            </el-col>
            <el-col :span="8">
              <span class="labelSpan">
                附件上传结束时间:
              </span>
              <span class="valueSpan">
                {{addForm.onlineFileEndtime}}
              </span>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>
<style>
  .info{
    border-radius: 10px;
    line-height: 20px;
    padding: 10px;
    margin: 10px;
    background-color: #ffffff;
  }
</style>
<script>
import UE from '@/components/ue/ue.vue'
import Loading from '@/components/loading/loading'
import pagination from '@/components/pagination/index'
import { getPartyInfoList, deletePartyInfo, addSearch, addPartyInfo } from '@/api/partyBranch/partyInfo'
import { isvalidNumber, isvalidRequire, isvalidSpecial } from '@/utils/validate'
// 非空
var validateRequire = (rule, value, callback) => {
  if (!isvalidRequire(value)) {
    callback(new Error('请输入必填项'))
  } else {
    callback()
  }
}
// 特殊字符
var validSpecial = (rule, value, callback) => {
  if (!isvalidSpecial(value)) {
    callback(new Error('数据不能包含特殊字符'))
  } else {
    callback()
  }
}
// 数字验证
var validNumber = (rule, value, callback) => {
  if (!isvalidNumber(value)) {
    callback(new Error('只能输入大于0的数字'))
  } else {
    callback()
  }
}
// import store from '@/store'
// import { MessageBox } from 'element-ui'
import axios from 'axios'
export default {
  components: {
    Loading,
    pagination,
    UE
  },
  data() {
    this.permissionHandle = this.$permissionHandle
    return {
      showFilelist: false,
      fileList: [],
      SeTime: [],
      importFileUrl: process.env.UPLOAD_URL + '/upload',
      importData: {
        fileKey: ''
      },
      defaultMsg: '',
      loading: false,
      paginations: {
        totalNum: 0,
        currentPage: 1,
        pageSize: 10
      },
      searchData: {
        partyWorkSort: '',
        partyWorkTypeKey: '',
        cycleAssessmenKey: '',
        pageSize: '10',
        pageNum: '1'
      },
      config: {
        initialFrameWidth: null,
        initialFrameHeight: 350
      },
      partyWorkSortList: [],
      partyWorkTypeKeyList: [],
      cycleAssessmenKeyList: [],
      editor: 'editor',
      addForm: {
        partyWorkInfoKey: '',
        cycleAssessmenKey: '',
        partyWorkTypeKey: '',
        partyWorkSort: '001',
        workTitle: '',
        fileKey: '',
        hostUser: '',
        recordTime: '',
        shouldNumber: '',
        actualNumber: '',
        joinUser: '',
        absentUser: '',
        content: '',
        onlineBegintime: '',
        onlineEndtime: '',
        onlineFileEndtime: ''
      },
      valueText: '',
      fileKeys: [],
      rules: {
        cycleAssessmenKey: [
          { required: true, message: '请选择年度考核周期', trigger: 'select' }
        ],
        partyWorkTypeKey: [
          { required: true, message: '请选择党务工作类型', trigger: 'select' }
        ],
        partyWorkSort: [
          { required: true, message: '请选择党务工作类别', trigger: 'select' }
        ],
        absentUser: [
          { message: '数据不能包含特殊字符', validator: validSpecial }
        ],
        workTitle: [
          { required: true, message: '请输入党务工作名称' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 42, message: '长度在 1 到 42个字符', trigger: 'blur' }
        ],
        hostUser: [
          { required: true, message: '请输入主持人姓名' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 21, message: '长度在 1 到 21个字符', trigger: 'blur' }
        ],
        recordTime: [
          { required: true, message: '请选择记录时间', trigger: 'blur' }
        ],
        shouldNumber: [
          { required: true, message: '请输入应到人数' },
          { type: 'number', validator: validNumber }
        ],
        actualNumber: [
          { required: true, message: '请输入实到人数' },
          { type: 'number', validator: validNumber }
        ],
        joinUser: [
          { required: true, message: '请输入到会人员' },
          { message: '数据不能包含特殊字符', validator: validateRequire }
        ],
        onlineBegintime: [
          { required: true, message: '请选择会议起止时间', trigger: 'blur' }
        ],
        onlineEndtime: [
          { required: true, message: '请选择会议起止时间', trigger: 'blur' }
        ],
        onlineFileEndtime: [
          { required: true, message: '请选择附件上传结束时间', trigger: 'blur' }
        ]
      },
      tableData: [],
      dialogFormVisible: false,
      detailFormVisible: false,
      editSearch: {
        key: ''
      },
      deleteDepArry: [],
      fileId: []
    }
  },
  watch: {
    dialogFormVisible: function() {
      if (!this.dialogFormVisible) {
        this.fileList = []
        this.defaultMsg = ''
        this.fileKeys = []
        this.addForm = {
          partyWorkInfoKey: '',
          cycleAssessmenKey: '',
          partyWorkTypeKey: '',
          partyWorkSort: '001',
          workTitle: '',
          fileKey: '',
          hostUser: '',
          recordTime: '',
          shouldNumber: '',
          actualNumber: '',
          joinUser: '',
          absentUser: '',
          content: '',
          onlineBegintime: '',
          onlineEndtime: '',
          onlineFileEndtime: ''
        }
      }
    },
    detailFormVisible: function() {
      if (!this.dialogFormVisible) {
        this.fileList = []
        this.defaultMsg = ''
        this.fileKeys = []
        this.addForm = {
          partyWorkInfoKey: '',
          cycleAssessmenKey: '',
          partyWorkTypeKey: '',
          partyWorkSort: '001',
          workTitle: '',
          fileKey: '',
          hostUser: '',
          recordTime: '',
          shouldNumber: '',
          actualNumber: '',
          joinUser: '',
          absentUser: '',
          content: '',
          onlineBegintime: '',
          onlineEndtime: '',
          onlineFileEndtime: ''
        }
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    resetSearch() {
      this.searchData.partyWorkSort = ''
      this.searchData.partyWorkTypeKey = ''
      this.searchData.cycleAssessmenKey = ''
      this.getList()
    },
    handlePreview(file) {
      if (file.id) {
        window.location.href = process.env.UPLOAD_URL + '/download/' + file.id
      }

      // axios({
      //   method: 'get',
      //   url: process.env.UPLOAD_URL + '/download/' + file.id
      // }).then(res => {

      // }).catch(error => {
      //   console.log(error)
      // })
    },
    handleRemove(file, fileList) {
      // this.liList.splice(index, 1)
      this.fileKeys.splice(this.fileKeys.findIndex(item => item === file.id), 1)
    },
    handleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
    },
    getFiles(file) {
      this.importData.fileKey = file
      const extension = file.size
      if (extension > (6 * 1024 * 1024)) {
        this.$message({
          message: '上传文件不能超过6M',
          type: 'warning'
        })
        return false
      }
      return true
    },
    // 上传成功后的回调
    uploadSuccess(response, file, fileList) {
      // if (response.code !== 200) {
      //   this.$message({
      //     message: response.msg,
      //     type: 'warning',
      //     duration: 3000
      //   })
      //   if (response.code === 401) {
      //     MessageBox.confirm('你已被登出，可以取消继续留在该页面，或者重新登录', '确定登出', {
      //       confirmButtonText: '重新登录',
      //       cancelButtonText: '取消',
      //       type: 'warning'
      //     }).then(() => {
      //       store.dispatch('FedLogOut').then(() => {
      //         location.reload() // 为了重新实例化vue-router对象 避免bug
      //       })
      //     })
      //   }
      // }
      if (response.error) {
        this.$message({
          message: response.error.msg,
          type: 'warning',
          duration: 3000
        })
      } else {
        this.fileKeys.push(response.id)
        this.showFilelist = true
      }
    },
    getId(index, row) {
      this.importData.infoId = row.id
    },
    // 上传错误
    uploadError(response, file, fileList) {
      this.$message({
        message: response.msg,
        type: 'warning',
        duration: 0,
        showClose: true
      })
    },
    // 上传前对文件的大小的判断
    beforeAvatarUpload(file, index, row) {
      return this.getFiles(file)
    },
    openDialog() {
      this.dialogFormVisible = true
      this.editSearch.key = ''
      this.getDetail('add')
    },
    getList() {
      this.loading = true
      getPartyInfoList(this.searchData).then(response => {
        this.loading = false
        this.tableData = response.data.entity.items
        this.paginations.totalNum = parseInt(response.data.entity.itemsTotalCount)
        this.partyWorkSortList = response.data.partyWorkSort
        this.partyWorkTypeKeyList = response.data.partyWorkType
        this.cycleAssessmenKeyList = response.data.dzbCycleAssessmen
      }).catch(error => {
        this.loading = false
        console.log(error)
      })
    },
    getUEContent() {
      const content = this.$refs.ue.getUEContent()
      this.$notify({
        title: '获取成功，可在控制台查看！',
        message: content,
        type: 'success'
      })
    },
    getDetail(param) {
      addSearch(this.editSearch).then(response => {
        this.loading = false

        if (response.data.entity) {
          this.addForm = response.data.entity
          if (this.addForm.content !== undefined) {
            this.defaultMsg = this.addForm.content
          } else {
            this.defaultMsg = ''
          }
          if (param === 'add') {
            this.addForm.partyWorkSort = '001'
          }
          if (this.addForm.fileKey) {
            this.fileKeys = this.addForm.fileKey.split(',')
            this.fileKeys.forEach(element => {
              axios({
                method: 'get',
                url: process.env.UPLOAD_URL + '/detail/' + element
              }).then(res => {
                if (res.data.data) {
                  this.fileList.push({
                    name: res.data.data.file_name,
                    url: res.data.data.file_path,
                    id: res.data.data.id
                  })
                  this.showFilelist = true
                } else {
                  this.fileList = []
                }
              }).catch(error => {
                console.log(error)
              })
            })
          }
        }

        this.partyWorkSortList = response.data.partyWorkSort
        this.partyWorkTypeKeyList = response.data.partyWorkType
        this.cycleAssessmenKeyList = response.data.dzbCycleAssessmen
      }).catch(error => {
        this.loading = false
        console.log(error)
      })
    },
    // 删除
    deleteParamsType() {
      if (this.deleteDepArry.length) {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          return new Promise((resolve, reject) => {
            deletePartyInfo({ 'keys': JSON.stringify(this.deleteDepArry) }).then(response => {
              resolve()
              this.loading = false
              this.getList()
              this.deleteDepArry = []
            }).catch(error => {
              this.loading = false
              this.deleteDepArry = []
              reject(error)
            })
          })
        }).catch(() => {
          this.deleteDepArry = []
          this.$refs.tableData.clearSelection()
          return
        })
      } else {
        this.$message({
          showClose: true,
          message: '请至少选择一条要删除的数据',
          type: 'warning'
        })
      }
    },
    handleDelete(index, row) {
      this.$refs.tableData.clearSelection()
      this.deleteDepArry = []
      this.deleteDepArry.push(row.partyWorkInfoKey)
      this.deleteParamsType()
    },
    handleSelectionChange(val) {
      this.deleteDepArry = []
      this.multipleSelection = val
      this.multipleSelection.forEach(element => {
        this.deleteDepArry.push(element.partyWorkInfoKey)
      })
    },
    handleSizeChange(val) {
      this.searchData.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.searchData.pageNum = val
      this.getList()
    },
    addParameter() {
      this.loading = true
      this.addForm.fileKey = this.fileKeys.toString()
      if (this.addForm.partyWorkSort === '001') {
        this.addForm.shouldNumber = parseInt(this.addForm.shouldNumber)
        this.addForm.actualNumber = parseInt(this.addForm.actualNumber)
        this.addForm.content = this.$refs.ue.getUEContent()
        this.addForm.onlineBegintime = ''
        this.addForm.onlineEndtime = ''
        this.addForm.onlineFileEndtime = ''
      } else {
        this.addForm.hostUser = ''
        this.addForm.recordTime = ''
        delete this.addForm['shouldNumber']
        delete this.addForm['actualNumber']
        this.addForm.joinUser = ''
        this.addForm.absentUser = ''
        this.addForm.content = ''
      }
      return new Promise((resolve, reject) => {
        addPartyInfo(this.addForm).then(response => {
          this.loading = false
          this.dialogFormVisible = false
          this.getList()
          resolve()
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.addParameter()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      // this.dialogFormVisible = false
      this.$refs[formName].resetFields()
    },
    handleEdit(index, row) {
      this.dialogFormVisible = true
      this.editSearch.key = row.partyWorkInfoKey
      this.getDetail('edit')
    },
    handledetail(index, row) {
      this.detailFormVisible = true
      this.editSearch.key = row.partyWorkInfoKey
      this.getDetail('edit')
    }
  }
}
</script>
<style lang="scss" scoped>
 .tree-select,.el-date-editor,.el-textarea{width: 100%;}
 .el-input{width: 100%;}
 p{    -webkit-margin-before: 0em;
    -webkit-margin-after: 0em;}
</style>

<style>
#editor{border:none;resize:none;}
</style>